<?php
if(!isset($_SESSION)) 
{ 
session_start(); 
} 
include '../operations/connection.php';	
include 'substring-comment.php';

$prdelete = $_REQUEST['prdelete'];
$id_testproject = $_REQUEST['idtestproject'];

		
if ($prdelete==0){
				$sqlupdate = "UPDATE pr_testproject SET `Delete` = 1 WHERE IDTest = '$id_testproject'";
				mysql_query($sqlupdate);
			}else{
				$sqlcomment = "DELETE FROM pr_comment WHERE pr_comment.IDTestProject = '$id_testproject'";
				mysql_query($sqlcomment);
				
				$sqldelete = "DELETE FROM pr_testproject WHERE pr_testproject.IDTest = '$id_testproject'";
				mysql_query($sqldelete);
				//attach delete
				$listattach = mysql_query('select filepath, filereal from pre_attach 
				where testprojectid='.$id_testproject);
				$flagattach = 0;
				while ($rowattach = mysql_fetch_array($listattach)) {
					$flagattach = 1;
					unlink($rowattach[filepath].$rowattach[filereal]);
					$flagattach = 1;
				}
				if ($flagattach == 0) {
					mysql_query("DELETE from pre_attach where testprojectid=".$id_testproject);
				}
}
$id = $_REQUEST['id'];

$page = isset ( $_GET["page"] ) ? intval ( $_GET["page"] ) : 1;
mysql_close($connection);

	header('Location: ../project.php?projectDetail=project-detail&id='.$id."&tab=1&page=".$page);
?>
			

